import { BaseSkill } from '../BaseSkill';
import { DamageType, SkillType } from '../../types';
import { General } from '../../models/General';
import { Battle } from '../../models/Battle';

export class GuWuJueJi extends BaseSkill {
  private readonly DAMAGE_REDUCTION = 0.35;  // 35% 伤害减免

  constructor() {
    super(
      'guWuJueJi',
      '固若金汤',
      SkillType.Active,
      DamageType.None,
      0.6,        // 60% 触发概率
      3,          // 3回合CD
      2           // 2回合持续
    );
  }

  execute(source: General, battle: Battle): void {
    if (!this.canUse() || Math.random() > this.probability) return;

    source.addEffect({
      type: 'damageReduction',
      value: this.DAMAGE_REDUCTION,
      duration: this.duration,
      stackable: false,
      source: this.id,
      timestamp: Date.now()
    });

    this.startCooldown();
  }
}
